Previous | Chapter contents | Next | Book PDF
Scripting support is the most automatic for applications based on the new document architecture for several reasons. First, NSDocument and the other classes of the document architecture directly implement the standard document scripting class (as expected by AppleScript) and automatically support many of the scripting commands that apply to documents. Second, because the document architecture is intended to work with application designs that use MVC separation, and because scripting support depends on many of the same design points, applications that use the document architecture are already in better shape to support scripting than other applications that are not designed that way. Finally, the document plays an important role in the scripting API of most applications; NSDocument knows how to fill that role and provides a good starting point for allowing scripted access to the model layer of your application.
You can make an application that is not based on the document architecture scriptable, but it is not as easy as with an application based on that architecture; you have to duplicate the work you would get for free if the application used the document architecture. The TextEdit example project gives an example of how to make a document-based application that is not based on NSDocument scriptable. See the Sketch example project for an example of how to implement a scriptable NSDocument-based application.
Previous | Chapter contents | Next | Book PDF